package com.tuniu.agents.tools.train;

import com.tuniu.agents.tools.train.tool.*;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Description;

@Configuration
@EnableConfigurationProperties(TrainProperties.class)
@ConditionalOnClass(TrainProperties.class)
@ConditionalOnProperty(prefix = "aigc.agents.tools.train", name = "enabled", havingValue = "true")
public class TrainAutoConfiguration {

    @Bean(SearchAllTrainTool.TOOLNAME)
    @ConditionalOnMissingBean
    @Description("Query all train schedules")
    @Tool(returnDirect = true)
    public SearchAllTrainTool searchAllTrain(TrainProperties properties) {
        return new SearchAllTrainTool(properties);
    }
    @Bean(SearchConditionTrainTool.TOOLNAME)
    @ConditionalOnMissingBean
    @Description("Query train schedules within a specified time range")
    @Tool(returnDirect = true)
    public SearchConditionTrainTool searchConditionTrain(TrainProperties properties) {
        return new SearchConditionTrainTool(properties);
    }

    @Bean(SearchTrainDetailTool.TOOLNAME)
    @ConditionalOnMissingBean
    @Description("View Train Details")
    @Tool(returnDirect = true)
    public SearchTrainDetailTool searchTrainDetail(TrainProperties properties) {
        return new SearchTrainDetailTool(properties);
    }
}